package o;

import android.content.Context;
import com.huawei.appgallery.serverreqkit.api.bean.BaseResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.gamebox.plugin.gameservice.bean.CheckSignResp;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import com.huawei.gamebox.plugin.gameservice.bean.GetGameBuoyInfoResp;
import com.huawei.gamebox.plugin.gameservice.bean.GetGameNoticeResp;
import com.huawei.gamebox.plugin.gameservice.bean.GetGameSubAccResp;
import com.huawei.gamebox.plugin.gameservice.bean.GetGameUpdateInfoResp;
import com.huawei.gamebox.service.usercenter.personal.bean.GetUserSummaryInfoRes;
import com.huawei.gamebox.service.usercenter.personal.bean.UserSummaryInfoBean;

public class fac extends ezj implements IServerCallBack {
    private long ʻ;
    private long ॱॱ;

    static class c implements IServerCallBack {
        private c() {
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            if ((responseBean instanceof StartupResponse) && responseBean.getRtnCode_() == 0) {
                ((StartupResponse) responseBean).ॱˎ();
            }
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        }
    }

    public fac(String str, fad o_fad) {
        super(str, o_fad);
    }

    public void ॱ(Context context, GameInfo gameInfo) {
        super.ॱ(context, gameInfo);
        this.ʻ = System.currentTimeMillis();
    }

    void ˎ(GameInfo gameInfo, String str, String str2, String str3, IServerCallBack iServerCallBack) {
        final GameInfo gameInfo2 = gameInfo;
        final String str4 = str;
        final String str5 = str2;
        final String str6 = str3;
        final IServerCallBack iServerCallBack2 = iServerCallBack;
        ˏ(false, new c(this) {
            final /* synthetic */ fac ʼ;

            public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                super.notifyResult(o_cvu, responseBean);
                fbh.ˋ(eyp.ˏ(gameInfo2, str4, str5, str6), iServerCallBack2);
                this.ʼ.ˋ(o_cvu, responseBean);
            }

            public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
            }
        });
    }

    public void ˊ(Context context, final GameInfo gameInfo, final String str) {
        this.ˎ = context;
        this.ˋ = gameInfo;
        ezy.ˏ().ॱ(this.ˊ);
        ˏ(true, new c(this) {
            final /* synthetic */ fac ॱ;

            public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                super.notifyResult(o_cvu, responseBean);
                eyd ˊ = ezb.ˊ(gameInfo, str);
                this.ॱ.ʻ = System.currentTimeMillis();
                fbh.ˋ(ˊ, this.ॱ);
            }
        });
    }

    void ॱ(final GameInfo gameInfo, final ccm o_ccm, final IServerCallBack iServerCallBack) {
        this.ˏ = o_ccm;
        ˏ(true, new c(this) {
            final /* synthetic */ fac ˏ;

            public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
                super.notifyResult(o_cvu, responseBean);
                fbh.ˋ(eyv.ˎ(gameInfo, o_ccm, ezq.ˏ().ˎ(gameInfo.getPackageName())), iServerCallBack);
            }
        });
    }

    private void ˏ(boolean z, IServerCallBack iServerCallBack) {
        int ˏ = cdn.ˏ(ContentManager.getInstant().getContext());
        if (ˏ != epr.ˎ().ˋ()) {
            if (Logger.ˎ()) {
                Logger.ˏ("GssApiProvider", "need to call front, curVersionCode:" + ˏ + ", old:" + epr.ˎ().ˋ());
            }
            cvt ˎ = cvv.ˎ();
            ˎ.setRequestType(o.cvu.RequestStrategy.ˏ);
            if (z) {
                ˎ.ˏ(1);
            }
            cfw.ˎ(ˎ, iServerCallBack);
            return;
        }
        ResponseBean startupResponse = new StartupResponse();
        startupResponse.setResponseCode(1);
        iServerCallBack.notifyResult(cvv.ˎ(), startupResponse);
    }

    public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
        this.ॱॱ = System.currentTimeMillis();
        ˋ(o_cvu, responseBean);
        if (responseBean instanceof CheckSignResp) {
            ˋ((CheckSignResp) responseBean);
        } else if (responseBean instanceof GetGameBuoyInfoResp) {
            ॱ((GetGameBuoyInfoResp) responseBean);
        } else if (responseBean instanceof GetGameUpdateInfoResp) {
            ˋ((GetGameUpdateInfoResp) responseBean);
        } else if (responseBean instanceof GetGameNoticeResp) {
            ˋ((GetGameNoticeResp) responseBean);
        } else if (responseBean instanceof GetUserSummaryInfoRes) {
            ˎ((GetUserSummaryInfoRes) responseBean);
        } else {
            super.notifyResult(o_cvu, responseBean);
        }
    }

    private void ˎ(GetUserSummaryInfoRes getUserSummaryInfoRes) {
        if (this.ॱ == null) {
            Logger.e("GssApiProvider", "callback == null");
            return;
        }
        try {
            if (getUserSummaryInfoRes.getResponseCode() == 0 && getUserSummaryInfoRes.getRtnCode_() == 0) {
                UserSummaryInfoBean ˊ = getUserSummaryInfoRes.ˊ();
                if (!(ˊ == null || ˊ.ˋ() == null)) {
                    this.ॱ.ˋ(this.ˊ, String.valueOf(ˊ.ˋ().ॱ()));
                    return;
                }
            }
            this.ॱ.ˋ(this.ˊ, null);
        } catch (Exception e) {
            Logger.e("GssApiProvider", "send the response to client exception");
        }
    }

    private void ˋ(GetGameNoticeResp getGameNoticeResp) {
        if (this.ॱ != null) {
            if (getGameNoticeResp != null && getGameNoticeResp.getResponseCode() == 0 && getGameNoticeResp.getRtnCode_() == 0 && getGameNoticeResp.ˋ() != null) {
                ezr.ˎ().ॱ(this.ˎ, this.ˋ, getGameNoticeResp, this.ʻ, this.ॱॱ, this.ॱ);
            }
            ezr.ˎ().ˎ(this.ॱ, getGameNoticeResp);
        }
    }

    public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
    }

    private void ˋ(CheckSignResp checkSignResp) {
        if (this.ॱ != null) {
            if (checkSignResp != null) {
                try {
                    if (checkSignResp.getRtnCode_() == 0 && checkSignResp.ˎ()) {
                        this.ॱ.ˎ(0);
                        return;
                    }
                } catch (Throwable e) {
                    Logger.ˋ("GssApiProvider", "send the response to client exception", e);
                    return;
                }
            }
            this.ॱ.ˎ(1);
        }
    }

    private void ॱ(final GetGameBuoyInfoResp getGameBuoyInfoResp) {
        getGameBuoyInfoResp.hasSubAcct_ = 1;
        ezv.ॱ().ˊ(this.ˏ, new o.ezv.c(this) {
            final /* synthetic */ fac ॱ;

            public void ॱ(BaseResponseBean baseResponseBean) {
                if (baseResponseBean != null && baseResponseBean.getRtnCode_() == 0) {
                    GetGameSubAccResp getGameSubAccResp = (GetGameSubAccResp) baseResponseBean;
                    if (getGameSubAccResp.ˎ() != null && getGameSubAccResp.ˎ().size() > 1) {
                        getGameBuoyInfoResp.hasSubAcct_ = 0;
                    }
                }
                this.ॱ.ˎ(getGameBuoyInfoResp);
            }
        });
    }

    private void ˋ(GetGameUpdateInfoResp getGameUpdateInfoResp) {
        long j = this.ॱॱ - this.ʻ;
        if (!ezy.ˏ().ॱ(this.ˋ) || getGameUpdateInfoResp == null || getGameUpdateInfoResp.getResponseCode() != 0 || getGameUpdateInfoResp.newVersion_ == null) {
            ˎ((ResponseBean) getGameUpdateInfoResp);
            return;
        }
        long ˏ = ezy.ˏ().ˏ(this.ˋ.getAppId());
        int ˏ2 = getGameUpdateInfoResp.newVersion_.ˏ();
        if (ˏ <= 0 || j <= ˏ || ˏ2 == 1) {
            ezy.ˏ().ॱ(this.ˋ.getAppId(), this.ॱ);
            ezy.ˏ().ˏ(this.ˋ.getAppId(), getGameUpdateInfoResp);
            ezy.ˏ().ˋ(this.ˋ);
            return;
        }
        ezy.ˏ().ˊ(this.ॱ, getGameUpdateInfoResp);
    }
}
